<template>
  <Scroll class="con">
    <ul>
      <li
        @click="itemClick(item, index)"
        class="listItem"
        :class="curIndex == index ? 'selected' : ''"
        v-for="(item, index) in cateList"
        :key="index"
      >
        {{ item.title }}
      </li>
    </ul>
  </Scroll>
</template>

<script>
import Scroll from "components/commom/scroll/scroll";
export default {
  props: {
    cateList: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  components: {
    Scroll,
  },
  data() {
    return {
      curIndex: 0,
    };
  },
  methods: {
    itemClick(item, index) {
      this.curIndex = index;
      console.log(item);
      this.$emit("itemClick", item.maitKey, item.miniWallkey);
    },
  },
};
</script>

<style scoped>
.con {
  position: fixed;
  left: 0;
  right: 75%;
  top: 40px;
  bottom: 49px;
  background-color: #eee;
}
.listItem {
  width: 100%;
  height: 40px;
  text-align: center;
  line-height: 40px;
  font-size: 14px;
  color: #666;
}
.selected {
  background-color: #fff;
  color: var(--bgColor);
  font-weight: bold;
  position: relative;
}
.selected::before {
  content: "";
  width: 2px;
  height: 40px;
  background-color: rgb(199, 12, 12);
  position: absolute;
  left: 0;
  top: 0;
}
</style>